package personal.hrsw1.demo1.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import personal.hrsw1.demo1.domain.Goods;
import personal.hrsw1.demo1.domain.SysOrder;
import personal.hrsw1.demo1.service.GoodsService;
import personal.hrsw1.demo1.service.SysOrderService;

import java.util.List;

@Controller
@RequestMapping("/syo")
public class Sys_orderController {
    @Autowired
    SysOrderService sysOrderService;

    @RequestMapping("list")
    public String list(Model model) {
        try {
            List<SysOrder> syo = sysOrderService.selectOrdersWithDetails();
            model.addAttribute("syo", syo);
            return "listSys_order";
        } catch (Exception e) {
            e.printStackTrace();
            model.addAttribute("errorMessage", "查询订单数据时发生错误，请联系管理员");
            return "errorPage";
        }
    }
}